package com.luozongyao.statistics.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luozongyao.statistics.entity.User;
import com.luozongyao.statistics.mapper.UserMapper;
import com.luozongyao.statistics.service.UserService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2021-10-25
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    //统计某天用户注册人数
    @Override
    public Integer registerCount(String day) {
        return baseMapper.selectRegisterCount(day);

    }

//    @Override
//    public Map<String, Object> getChartData(String begin, String end) {
//        QueryWrapper<User> wrapper = new QueryWrapper<>();
//        wrapper.between("create_time",begin,end);
//        List<User> userList = baseMapper.selectList(wrapper);
//        //因为返回有两部分数据:日期和日期对应数量
//        //前端要求数组json结构，对应后端java代码是list集合
//        // 创建两个list集合，一个日期list，一个数量list
//        Map<String, Object> map = new HashMap<>();
//        List<Integer> dataList = new ArrayList<Integer>();
//        List<Date> dateList = new ArrayList<Date>();
//        map.put("dataList", dataList);
//        map.put("dateList", dateList);
//        baseMapper.selectCount(wrapper);
//
//        for (int i = 0; i < userList.size(); i++) {
//            User user = userList.get(i);
//            dateList.add(user.getCreateTime());
//            dataList.add(count(wrapper));
//        }
//
////        for (int i = 0; i < dailyList.size(); i++) {
////            StatisticsDaily daily = dailyList.get(i);
////            dateList.add(daily.getDateCalculated());
////            //判断查询的啥类型 登录数量 注册数量 视频浏览数 课程购买数进行查询
////            switch (type){
////                case "login_num":
////                    dataList.add(daily.getLoginNum());
////                    break;
////                case "register_num":
////                    dataList.add(daily.getRegisterNum());
////                    break;
////                case "video_view_num":
////                    dataList.add(daily.getVideoViewNum());
////                    break;
////                case "course_num":
////                    dataList.add(daily.getCourseNum());
////                    break;
////                default:
////                    break;
////            }
////        }
//        return map;
//    }
}
